package cn.sccl.dirms.topo.discovery.service.impl;

import cn.sccl.common.dao.BaseDAO;
import cn.sccl.common.database.DataBase;
import cn.sccl.common.model.PageResult;
import cn.sccl.common.model.QueryData;
import cn.sccl.common.service.impl.BaseManagerImpl;
import cn.sccl.dirms.topo.discovery.dao.DiscoverTaskLogDAO;
import cn.sccl.dirms.topo.discovery.model.DiscoverTaskLog;
import cn.sccl.dirms.topo.discovery.service.DiscoverTaskLogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* 自动发现规则 的Manager实现类
* Created by _minus on 2017-09-25.
*/
@Service
public class DiscoverTaskLogManagerImpl extends BaseManagerImpl<DiscoverTaskLog> implements DiscoverTaskLogManager{

    @Autowired
    private DiscoverTaskLogDAO discoverTaskLogDAO;

    @Autowired
    private DataBase dataBase ;

    @Override
    public DataBase getDataBase(){return this.dataBase ;}


    public DiscoverTaskLogDAO getDiscoverTaskLogDAO(){
        return discoverTaskLogDAO;
    }

    @Override
    public BaseDAO<DiscoverTaskLog> getBaseDAO(){
        return getDiscoverTaskLogDAO();
    }


    @Override
    public PageResult<DiscoverTaskLog> pageQueryTaskFireLogsByTaskId(String fireLogId, long pageIndex, int pageSize, QueryData queryData) {
        StringBuffer sb =new StringBuffer();
        sb.append(
                "SELECT *\n" +
                        "  FROM T_TOPO_DISCOVER_TASK_LOG DTL\n" +
                        " WHERE DTL.DELETE_FLAG = 0\n" +
                        "   AND DTL.TASK_FIRE_LOG_ID =?\n" +
                        " ORDER BY CREATE_TIME DESC"
        );
        List params = new ArrayList();
        params.add(fireLogId);
        return getDataBase().query4Model(sb.toString(),pageIndex,pageSize,DiscoverTaskLog.class,params.toArray());
    }
}